"""
利用列表和元组实现线性Map的add 和 get
author: Mr_52Hz
date: 2019-11-09
"""


class LinkMap(object):

    def __init__(self):
        self.maps = list()

    def add(self, key, value):
        self.maps.append((key, value))

    def get(self, key):

        for k, v in self.maps:
            if k == key:
                return v
        return None

    def __str__(self):
        return str(self.maps)


if __name__ == '__main__':
    lm = LinkMap()
    lm.add('name', 'laowang')
    print(lm)


